package main

import (
	"context"
	"fmt"
	"project1/day05/pb"

	"google.golang.org/grpc"
)

func main() {
	//1.连接grpc服务
	grpcConn, err := grpc.Dial("127.0.0.1:8800", grpc.WithInsecure()) //表示以安全的方式
	if err != nil {
		fmt.Println("Dial err:", err)
		return
	}
	defer grpcConn.Close()
	//2.初始化grpc客户端
	grpcClient := pb.NewSayNameClient(grpcConn)

	//创建并初始化一个Teacher对象
	var teacher pb.Teacher
	teacher.Name = "itcast"
	teacher.Age = 18

	//3.调用远程服务
	t, err := grpcClient.SayHello(context.TODO(), &teacher)

	fmt.Println(t, err)
}
